<template>
  <div class="gi_table_page">
    <GiTable
      title="订单明细管理"
      row-key="id"
      :data="dataList"
      :columns="columns"
      :loading="loading"
      :scroll="{ x: '100%', y: '100%', minWidth: 1000 }"
      :pagination="pagination"
      :disabled-tools="['size']"
      :disabled-column-keys="['name']"
      @refresh="search"
    >
      <template #toolbar-left>
        <a-button @click="reset">
          <template #icon><icon-refresh /></template>
          <template #default>重置</template>
        </a-button>
      </template>
    </GiTable>
  </div>
</template>

<script setup lang="ts">
import type { TableInstance } from '@arco-design/web-vue'
import { type OrderDetailQuery, listOrderDetail } from '@/apis/cakerun/orderDetail'
import { useTable } from '@/hooks'

defineOptions({ name: 'OrderDetail' })

const queryForm = reactive<OrderDetailQuery>({
  sort: ['id,desc'],
})

const {
  tableData: dataList,
  loading,
  pagination,
  search,
} = useTable((page) => listOrderDetail({ ...queryForm, ...page }), { immediate: true })
const columns: TableInstance['columns'] = [
  { title: '业务时间', dataIndex: 'businessTime', slotName: 'businessTime', width: 100 },
  { title: '添加时间', dataIndex: 'addTime', slotName: 'addTime', width: 100 },
  { title: '订单ID', dataIndex: 'orderId', slotName: 'orderId', width: 100 },
  { title: '优惠金额', dataIndex: 'discountAmount', slotName: 'discountAmount', width: 100 },
  { title: '原始业务类型', dataIndex: 'originalBizType', slotName: 'originalBizType', width: 140 },
  { title: '押金金额', dataIndex: 'depositAmount', slotName: 'depositAmount', width: 100 },
  { title: '美团退款金额', dataIndex: 'mtRefund', slotName: 'mtRefund', width: 120 },
  { title: '配送优惠金额', dataIndex: 'deliverDiscountFee', slotName: 'deliverDiscountFee', width: 120 },
  { title: '争议订单号', dataIndex: 'disputeOrderNo', slotName: 'disputeOrderNo', width: 120 },
  { title: '实付金额', dataIndex: 'realPayed', slotName: 'realPayed', width: 100 },
  { title: '业务成本', dataIndex: 'bizCost', slotName: 'bizCost', width: 100 },
  { title: '账户ID', dataIndex: 'accountId', slotName: 'accountId', width: 100 },
  { title: '团购收入', dataIndex: 'groupBuyIncoming', slotName: 'groupBuyIncoming', width: 120 },
  { title: '订单创建时间', dataIndex: 'orderCreateTime', slotName: 'orderCreateTime', width: 120 },
  { title: '结算状态', dataIndex: 'traceSettleStatus', slotName: 'traceSettleStatus', width: 100 },
  { title: '交易开始时间', dataIndex: 'dealStartTime', slotName: 'dealStartTime', width: 120 },
  { title: '券包ID', dataIndex: 'voucherPackageId', slotName: 'voucherPackageId', width: 100 },
  { title: '数据时间', dataIndex: 'dataTime', slotName: 'dataTime', width: 100 },
  { title: '退款金额', dataIndex: 'refund', slotName: 'refund', width: 100 },
  { title: '账户名称', dataIndex: 'accountName', slotName: 'accountName', width: 100 },
  { title: '商家自配送费', dataIndex: 'partnerSelfDeliverFee', slotName: 'partnerSelfDeliverFee', width: 160 },
  { title: '交易ID', dataIndex: 'dealId', slotName: 'dealId', width: 100 },
  { title: '备注', dataIndex: 'remark', slotName: 'remark', width: 100 },
  { title: '流水类型显示名称', dataIndex: 'traceTypeShowName', slotName: 'traceTypeShowName', width: 200 },
  { title: '门店ID', dataIndex: 'poiId', slotName: 'poiId', width: 100 },
  { title: '门店城市', dataIndex: 'poiCity', slotName: 'poiCity', width: 100 },
  { title: '门店名称', dataIndex: 'poiName', slotName: 'poiName', width: 100 },
  { title: '储值卡扣款金额', dataIndex: 'savingCardDeductAmount', slotName: 'savingCardDeductAmount', width: 200 },
  { title: '配送费', dataIndex: 'deliveryFee', slotName: 'deliveryFee', width: 100 },
  { title: '原始金额', dataIndex: 'originalAmount', slotName: 'originalAmount' },
  { title: '应付金额', dataIndex: 'due', slotName: 'due', width: 100 },
  { title: '分摊金额', dataIndex: 'sharedAmount', slotName: 'sharedAmount', width: 100 },
  { title: '服务费', dataIndex: 'service', slotName: 'service', width: 100 },
]

// 重置
const reset = () => {
  search()
}
</script>

<style scoped lang="scss"></style>
